import Vue from 'vue'
import Vuex from 'vuex'
import rq from '../../requests'
import router from '../../router'
import qs from 'qs'
import { Notify } from 'vant';
import global from "../../global";
Vue.use(Vuex);

export default {
  namespaced: true,
  state: {
    timerHandler: null,
    thisContext: null,
    thisVideo: null,
    videoWidth: 300,
    videoHeight: 300,
    thisCancas: null,
  },
  mutations: {
    setTimerHandler(state, {timerHandler}) {
      state.timerHandler = timerHandler;
    },
    setVideoContext(state, {thisContext, thisVideo, thisCancas}) {
      state.thisContext = thisContext;
      state.thisVideo = thisVideo;
      state.thisCancas = thisCancas;
    }
  },
  getters: {
    
  },
  actions: {
    "SOCKET_openRecordFeedback"({state}, data) {
      console.log("SOCKET_openRecordFeedback, ");
    },
    parse({ commit, state, rootState, dispatch }, { blob, callback }) {
      console.log("Enter parse ,groupToken: ", groupToken);
      let formData = new FormData();
      let groupToken = rootState.group.selectedGroupToken || "";
      formData.append('file', blob);
      formData.append('groupToken', groupToken);

      let config = {
        headers: {
          'Content-Type': 'multipart/form-data'
        }
      };
      rq.requests.post("/fic/speech/parse", formData, config)
      .then(({ eCode, res, eMessage }) => {
        if (!eCode) {
          callback(res);
          return;
        } 
        Notify({ type: 'danger', message: eMessage });
      });
    }
  }
}

